package config

const (
	ReadBufMaxLen = 1024 * 1024
)

const (
	CommonClientLoginReq  = 0x10000200 + iota //客户端登录请求
	CommonClientLoginRet                      //客户端登录返回
	CommonUserLoginReq                        //用户登录请求
	CommonUserLoginRet                        //用户登录返回
	CommonUserLogoutReq                       //用户登出请求
	CommonUserLogoutRet                       //用户登出返回
	CommonPushMsgRet      = 0x10000211        //消息推送通知
	CommonKeepAliveReq    = 0x10000020        //全局心跳请求
	CommonKeepAliveRet    = 0x10000021        //全局心跳返回
	CommonExecCmdReq      = 0x10000401        //CONSOLE控制台执行命令请求
	CommonExecCmdRet      = 0x10000403        //终端执行命令结果返回
	CommonConsoleLogin    = 0x10000301        //CONSOLE控制台服务登录请求
	CommonAgentLost       = 0x10000501        //AGENT会话未找到
	CommonAgentLoginReq   = 0x10000600        //AGENT登录请求
	CommonAgentLoginRet   = 0x10000601        //AGENT登录返回
	CommonAgentChannelReq = 0x10000602        //AGENT安全通道建立请求
	CommonAgentChannelRet = 0x10000603        //AGENT安全通道建立返回
	CommonAgentChannelAck = 0x10000604        //AGENT安全通道建立确认
	CommonAgentLogoutReq  = 0x10000606        //AGENT主动退出请求
)

const (
	LcActionConnect    = "on"
	LcActionDisconnect = "off"
	LcSalt             = "sFlow"
	LcBusinessType     = "remote_assistance"
)

const (
	AgentChildUnreachable = "child-unreachable"
	AgentChildRunning     = "child-running"
	AgentChildStarted     = "child-started"
)

const (
	AgentInit = 0 + iota
	AgentConnected
	AgentReady
	AgentExcept
	AgentNotSupportV6
	AgentDisconnected
	AgentExecDoing
	AgentExecTimeout
	AgentRunning
	AgentSuccess
)

const (
	FlowClientKey    = "client"
	FlowManageKey    = "flow_manage_map"
	FlowContainerKey = "flow_container_map"
	FlowTaskKey      = "flow_task_map"
	FlowNotV6Key     = "flow_not_v6_map"
)

const (
	TaskInit       = 0
	TaskCycleReady = 1
	TaskDoing      = 2
	TaskDoingWait  = 3
	TaskFinish     = 4
)

const (
	CustomWorkerCount = 10
	WorkerCount       = 150
	MaxLimit          = 4 * WorkerCount
	TaskDefaultRate   = 10 * 1000 * 1000
	TaskAgentDuration = 2 * 60
	LoserDuration     = 20 * 60
)

const (
	IspCustom       = "CUSTOM"
	IspTelecom      = "CT"
	IspMobile       = "CM"
	IspUnicom       = "CU"
	IspHumaCustom   = "沙盒"
	IspHumanTelecom = "电信"
	IspHumanMobile  = "移动"
	IspHumanUnicom  = "联通"
)

func GetIspHuman(isp string) string {
	switch isp {
	case IspCustom:
		return IspHumaCustom
	case IspTelecom:
		return IspHumanTelecom
	case IspMobile:
		return IspHumanMobile
	case IspUnicom:
		return IspHumanUnicom
	default:
		return ""
	}
}

func GetConsoleInfo(index int) *ConsoleInfo {
	return &AppConfig().Console.Servers[index]
}
